<?php


namespace app\api\controller;


use app\common\controller\Api;

class Poster extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    //信息
    public function index()
    {
        $this->success('成功',\app\common\model\Poster::all());
    }

    /**
     * 生成海报
     * @author Created by Xing <464401240@qq.com>
     */
    public function getposter($poster_id = null)
    {
        $poster =    \app\common\model\Poster::get($poster_id);
        if (!$poster) {
            $this->error(__('未找到海报' . $poster_id));
        }
        $image = new \addons\poster\library\Image();
        $imgurl = $image->createPosterImage($poster, $this->auth->getUser());

        if (!$imgurl) {
            $this->error('生成海报出错');
        }

        $this->success('', cdnurl($imgurl) );
    }
}